<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<head>
	<meta charset="UTF-8">
	<meta name="apple-mobile-web-capable" content="yes">
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/voiceStyle.css">
</head>
<style>
	.lunul {
		list-style: none;
	}
	.lunBo{
		text-align: center;
		position: relative;
	}
	.lunBo .banner .item{
		display: none;
	}
	.lunBo .banner .item.active{
		display: block;
	}
	.lunBo .banner .item a{
		border: none;
	}
	.lunul{
		position: absolute;
		overflow: hidden;
		bottom: 10px;

	}
	.lunul li{
		float: left;
		width: 20px;
		font:bold 14px/20px "微软雅黑";
		background-color:#9BCD9B;
		color: #fff;
		text-align: center;
		cursor: default;
		border-radius: 15px;

	}
	.lunul li+li{
		margin-left: 10px;
	}
	.lunul li.active{
		background-color: #fff;
		color: red;
	}
</style>

<script type="text/javascript"
		src="${pageContext.request.contextPath}/js/AudioRecorder.js"></script>
<script>

    var search_keyWord = "",fileName="",evaluateId = "",row;
    var basePath = "https://5151px.com";
    $(function() {
        init();
        searchAction();
        bootstrapValidatorInit();
    })

    function init() {

        if (store.get('userRole') == "2") {
            $("#teacherSearch").val(store.get('userRealName'));
            $("#teacherSearch").attr("disabled", "disabled");
            searchTeacherCourse(store.get('userId'));
        }else{
            searchCourse("#lessonNameSearch");
		}
        dataListInit();

        $('.form_date').datetimepicker({
            format:'yyyy-mm-dd',
            language : 'zh-CN',
            weekStart : 1,
            todayBtn : 1,
            autoClose : 1,
            todayHighlight : 1,
            startView : 2,
            forceParse : 0,
            minView:2
        });
    }
    // 搜索动作
    function searchAction() {
        $('#search_button').click(function() {
            search_keyWord = $('#search_input').val();
            tableRefresh();
        })
    }

    //搜索课程列表
    function searchCourse(courseName){
        $.ajax({
            url:"/onlineEdu/lesson/getLessonGroup",
            type: 'GET',
            cache: false,
            data:{},
            dataType:  "json",
            async:false,
            success: function (data) {
                var options = '<option value="">--请选择--</option>'+data.lessonGroup;
                $(courseName).html(options);
            }
        });
    }

    function searchTeacherCourse(teacherName){
        $.ajax({
            url:"/onlineEdu/lesson/getTeacherLessonGroup",
            type: 'GET',
            cache: false,
            data:{
                teacherId:teacherName
            },
            dataType:  "json",
            async:false,
            success: function (data) {
                // var options = '<option value="">---</option>'+data.teacherLessonGroup;
                var options = data.teacherLessonGroup;
                $("#lessonNameSearch").html(options);
            }
        });
    }

    // 分页查询参数
    function queryParams(params) {

        var temp = {
            limit : params.limit,
            offset : params.offset,
            lessonName :$('#lessonNameSearch').val(),
            startTime:$('#startTimeSearch').val()==""?"":$('#startTimeSearch').val()+" 00:00:00",
            endTime:$('#endTimeSearch').val()==""?"":$('#endTimeSearch').val()+" 23:59:59"
        }
        return temp;
    }

    // 表格初始化
    function dataListInit() {
        $('#dataList').bootstrapTable(
            {
                columns : [{
                    checkbox: true,
                    align: 'center'
                }, {
                    title: 'ID',
                    formatter: function (value, row, index) {
                        return index+1;
                    },
                    align: "center"
                },
                    {
                        field : 'lesson_name',
                        title : '课程名称'
                    },
                    {
                        field : 'content',
                        title : '评价内容'
                    },
                    {
                        field : 'create_time',
                        title : '评价时间'
                    },
                    {
                        field : 'operation',
                        title : '操作',
                        width: 160,
                        align: 'center',
                        valign: 'middle',
                        formatter : function(value, row, index) {
                            var c = '<button class="btn btn-danger btn-sm del"><span>删除</span></button>';
                            return c;
                        },
                        events : {
                            'click .del' : function(e, value, row, index) {
                                if (store.get('userRole') == "0") {
                                    evaluateId = row.evaluate_id;
                                    $('#deleteWarning_modal').modal("show");
                                }else{
                                    alert("请联系管理员删除！");
                                }
                            }
                        }
                    } ],
                url : '/onlineEdu/teacher/teacherEvaluate',
                onLoadError:function(status){
                    handleAjaxError(status);
                },
                method : 'GET',
                queryParams : queryParams,
                sidePagination : "server",
                dataType : 'json',
                pagination : true,
                pageNumber : 1,
                pageSize: 10,
                pageList : [5, 10, 25, 50, 100 ]
            });
    }

    // 表格刷新
    function tableRefresh() {
        $('#dataList').bootstrapTable('refresh', {
            query : {}
        });
    }

    $('#delete_confirm').click(function() {

        $.ajax({
            type : "GET",
            url :"/onlineEdu/teacher/deleteEvaluate",
            dataType : "json",
            data : {evaluateId:evaluateId},
            success : function(response) {
                $('#deleteWarning_modal').modal("hide");
                var msg;
                var type;
                var append = '';
                if (response.result == "success") {
                    type = "success";
                    msg = "删除成功";
                } else if (response.result == "error") {
                    type = "error";
                    msg = "删除失败";
                }
                showMsg(type, msg, msg);
                $("#delText").html(msg);
                tableRefresh();
            },
            error : function(xhr, textStatus, errorThrown) {
                $('#deleteWarning_modal').modal("hide");
                handleAjaxError(xhr.status);
            }
        })
    });
</script>
<div class="panel panel-default">
	<ol class="breadcrumb">
		<li><label class="form-label">学生作业信息</label></li>
	</ol>
	<div class="panel-body">
		<div class="row">
			<div style="width: 100%;margin-top: -16px" class="box-content">
				<table id="信息查询" class="table table-bordered table-hover table-responsive">
					<tbody>
					<tr>
						<td class="item-title" align="center">课程名称</td>
						<td class="item-content-half">
							<%--<input type="text" class="form-control" id="lessonNameSearch" placeholder="">--%>
                            <select id="lessonNameSearch" class="form-control">
                            </select>
						</td>
						<td class="item-title" align="center">评价日期</td>
						<td class="item-content-half" style="text-align: left;width: 300px;">
							<input type="text" style="width: 130px;display: inline-block" class="form_date form-control" id="startTimeSearch" placeholder="">
							--<input type="text" style="width: 130px;display: inline-block" class="form_date form-control" id="endTimeSearch" placeholder="">
						</td>
					</tr>
					</tbody>
				</table>
			</div>
		</div>
		<div style="text-align: right">
			<button id="search_button" style="text-align: right" class="btn btn-success">
				<span class="glyphicon glyphicon-search"></span> <span>查询</span>
			</button>
		</div>
	</div>
	<div class="row" style="margin-top: 15px">
		<div class="col-md-12">
			<table id="dataList" class="table table-striped"></table>
		</div>
	</div>
</div>
</div>

<!-- 删除提示模态框 -->
<div class="modal fade" id="deleteWarning_modal" table-index="-1"
	 role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button class="close" type="button" data-dismiss="modal"
						aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="myModalLabelee">警告</h4>
			</div>
			<div class="modal-body">
				<div class="row">
					<div class="col-md-3 col-sm-3" style="text-align: center;">
						<img src="" alt=""
							 style="width: 70px; height: 70px; margin-top: 20px;">
					</div>
					<div class="col-md-8 col-sm-8">
						<h3 id="delText">是否确认删除该条记录</h3>
						<p></p>
					</div>
				</div>
			</div>
			<div class="modal-footer">
				<button class="btn btn-default" type="button" data-dismiss="modal">
					<span>取消</span>
				</button>
				<button class="btn btn-danger" type="button" id="delete_confirm">
					<span>确认删除</span>
				</button>
			</div>
		</div>
	</div>
</div>
